package com.whty.module.controller;

import java.util.List;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.whty.common.annotation.Log;
import com.whty.common.base.AjaxResult;
import com.whty.common.enums.BusinessType;
import com.whty.framework.web.page.TableDataInfo;
import com.whty.system.domain.PublishManagement;
import com.whty.system.service.IPublishManagementService;
import com.whty.web.core.base.BaseController;

/**
 * 发行管理 信息操作处理
 * 
 * @author mario
 * @date 2018-10-26
 */
@Controller
@RequestMapping("/module/publishManagement")
public class PublishManagementController extends BaseController
{
    private String prefix = "module/publishManagement";
	
	@Autowired
	private IPublishManagementService publishManagementService;
	
	@RequiresPermissions("module:publishManagement:view")
	@GetMapping()
	public String publishManagement()
	{
	    return prefix + "/publishManagement";
	}
	
	/**
	 * 查询发行管理列表
	 */
	@RequiresPermissions("module:publishManagement:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(PublishManagement publishManagement)
	{
		startPage();
        List<PublishManagement> list = publishManagementService.selectPublishManagementList(publishManagement);
		return getDataTable(list);
	}
	
	/**
	 * 新增发行管理
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存发行管理
	 */
	@RequiresPermissions("module:publishManagement:add")
	@Log(title = "发行管理", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(PublishManagement publishManagement)
	{		
		return toAjax(publishManagementService.insertPublishManagement(publishManagement));
	}

	/**
	 * 修改发行管理
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") Long id, ModelMap mmap)
	{
		PublishManagement publishManagement = publishManagementService.selectPublishManagementById(id);
		mmap.put("publishManagement", publishManagement);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存发行管理
	 */
	@RequiresPermissions("module:publishManagement:edit")
	@Log(title = "发行管理", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(PublishManagement publishManagement)
	{		
		return toAjax(publishManagementService.updatePublishManagement(publishManagement));
	}
	
	/**
	 * 删除发行管理
	 */
	@RequiresPermissions("module:publishManagement:remove")
	@Log(title = "发行管理", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(publishManagementService.deletePublishManagementByIds(ids));
	}
	
}
